home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9424 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: netline-fddi.jpl.nasa.gov!usenet
  2. From: David Yan <yan@aig.jpl.nasa.gov>
  3. Newsgroups: comp.lang.c++
  4. Subject: HELP: Sorting linked lists in STL
  5. Date: Fri, 01 Mar 1996 09:52:40 -0800
  6. Organization: Jet Propulsion Laboratory
  7. Message-ID: <31373968.55AC@aig.jpl.nasa.gov>
  8. NNTP-Posting-Host: keynes.jpl.nasa.gov
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 2.0 (X11; I; SunOS 5.4 sun4m)
  13.  
  14. I am having problems with the sort() method of the list<T> class in STL. 
  15.  
  16. I have a linked list which is declared as list<foo*> and have the
  17. operator < overloaded:
  18.  
  19. bool operator < (const foo *a, const foo *b) const
  20. { // some debug print statements
  21.     return *a < *b; 
  22. }
  23.  
  24. bool foo::operator < (const foo &b) const
  25. // some debug print statement and some operations ... 
  26. }
  27.  
  28.  
  29. STL specs say that list<T>::sort() makes use of the operator < of T 
  30. to sort the linked list.
  31. But unfortunately, when I call list<foo*>::sort(), both of the above
  32. overloaded operator < are not called.  
  33.  
  34. (I am using SparcWorks 4.0 with ObjectSpace STL.)
  35.  
  36. Any input will be much appreciated.
  37.  
  38. David Yan
  39. yan@aig.jpl.nasa.gov
  40.